// import fs from 'node:fs'
import { ElNotification } from 'element-plus'

/** 保存文件 */
/*export function saveFile(path: string, content: string) {
  fs.writeFileSync(path, content)
}

export function saveFileFromObject(path: string, content: object) {
  try {
    saveFile(path, JSON.stringify(content))
    commonSuccess('配置保存成功')
  }
  catch (e) {
    console.error(e)
    commonFail('配置保存失败')
  }
} */

export function saveCacheFromObject(key: string, content: object) {
  try {
    localStorage.setItem(key, JSON.stringify(content))
    // commonSuccess('配置保存成功')
    ElNotification({
      title: '操作成功',
      message: '配置保存成功',
      type: 'success',
    })
  }
  catch (e) {
    console.error(e)
    ElNotification({
      title: '操作失败',
      message: '配置保存失败',
      type: 'error',
    })
  }
}
